'use strict';

angular.module('myApp.tuition_add', [])

.controller('tuition_addCtrl', ['$scope','$http', 
    function($scope,$http) {
        $http.get('v1/student').success(function(data){
            $scope.model = data.message['data'];
        });
        $http.get('v1/school').success(function(data){
            $scope.nodel = data.result['data'];
        });
        $http.get('v1/teacher').success(function(data){
            $scope.podel = data.result['data'];
        });

        $scope.submit = function(tuition){
            tuition.stuid = $scope.m;
            tuition.school_id = $scope.n;
            tuition.create_teacher_id = $scope.p;
        	$scope.tem = angular.copy(tuition);
        	console.log($scope.tem);
		    $http.post('v1/tuition',$scope.tem).success(function(data){
	            if( !data.error ){
	                alert("添加成功","success");
	            window.location.href = '#/tuition_record';
	            }else{
	                alert(data.message);
	            }
		    });

        }
    // 日历
    $('.form-date').datetimepicker(
    {
        language:  'zh-CN',
        weekStart: 1,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        startView: 2,
        minView: 2,
        forceParse: 0,
        format: 'yyyy-mm-dd'
    });	$("new_button")
}]);